/**
 * 
 */
package org.rollinitiative.d20web.charactersheet.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * @author bebopjmm
 * 
 */
public class DefenseView extends Composite
{

    private final TextBox acRegularText = new TextBox();

    private final RadioButton isFlatFooted = new RadioButton("defenseGroup", "Flat-Footed");

    private final TextBox acTouchText = new TextBox();

    private final FlexTable armorTable_ = new FlexTable();


    public DefenseView()
    {
        VerticalPanel panel = new VerticalPanel();
        // panel.setBorderWidth(1);
        panel.add(new Label("Defense Stats"));
        Grid defenseGrid = new Grid(3, 2);
        defenseGrid.setWidget(0, 0, new Label("AC Regular:"));
        defenseGrid.setWidget(0, 1, acRegularText);
        acRegularText.setSize("4em", "2em");
        defenseGrid.setWidget(1, 0, new Label("AC Touch:"));
        defenseGrid.setWidget(1, 1, acTouchText);
        acTouchText.setSize("4em", "2em");
//        defenseGrid.setWidget(2, 0, new Label("AC Flat-footed:"));
        defenseGrid.setWidget(2, 0, isFlatFooted);
        isFlatFooted.setSize("4em", "2em");
        panel.add(defenseGrid);
        panel.add(new Label("Armor"));
        panel.add(armorTable_);

        initWidget(panel);
        initView();
    }


    private void initView()
    {
        acRegularText.setText("0");
        isFlatFooted.setChecked(true);
        isFlatFooted.setEnabled(false);
        acTouchText.setText("0");

        armorTable_.setWidget(0, 0, new Label("not yet implemented"));

    }
    
    public void setCharacter(CombatData combat)
    {
        acRegularText.setText("" + combat.getRegularAC());
        acTouchText.setText("" + combat.getTouchAC());
        isFlatFooted.setChecked(combat.isFlatFooted());
    }
}
